﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Security;


using System.Xml.Linq;
using System.Xml;
using System.Collections;
using System.Globalization;
using System.IO;

using SPBusiness.ExtensionMethods;

namespace SPBusiness
{
   public sealed class Feature
    {
       /// <summary>
       /// Feature class has only Static Methods, no constructor needed.
       /// </summary>
       private Feature() { }
        public static SPFeatureDefinition GetSPFeatureDefinition(SPWeb pSPWeb, Guid pDefinitionId)
        {
            try
            {
                SPFeatureDefinition vReturn = null;

                SPFeature vSPFeature = pSPWeb.Features.OfType<SPFeature>().FirstOrDefault(x => x.DefinitionId == pDefinitionId);

                if (vSPFeature != null)
                {
                    vReturn = vSPFeature.Definition;
                }

                return vReturn;
            }
            catch (Exception ex)
            {
                Logging.LogMessase(typeof(Feature).Namespace, typeof(Feature).Name, "GetSPFeatureDefinition", ex);
                throw;
            }
        }


      }
}
